Linking To ClientProtector Using Microsoft Visual Basic

SoftwareShield ClientProtector COM Component > Linking To ClientProtector In Your Application > Linking To ClientProtector™ Using Microsoft Visual Basic®

## Linking To ClientProtector™ Using Microsoft Visual Basic®

Please be sure you have read Linking To The ClientProtector COM Component In Your Application before you perform this procedure.

If you run into trouble, you may prefer to start with the Sample Code. There are a set of three complete compile-able VB6 programs available.

The following example was prepared and tested in Microsoft Visual Basic 6.0.

The method we use here involves creating a reference to the COM object using the IDE. This is very easy to use.

1. Open Visual Basic. Open a new or existing project in which you want to use the ClientProtector.
2. From the menu - select: "Project > References". The "Project References" dialog will pop-up. (See image below.)
3. In the Project References dialog that pops up, find and check the "SoftwareShield ClientProtector" (Note if you have the debug version registered, it will say "SoftwareShield DEBUG ClientProtector" - that is OK.
4. Declare a global object in your main form, like this:
   ' The ClientProtector
   Dim WithEvents SSCP As SSCProtector

5. Using the "Object" and "Procedure" combo-boxes in the IDE, connect any event handlers you need simply by selecting the object "SSCP" and then selecting the appropriate event - the handler will be automatically created and connected for you.

6. You can now use the component in this application. In the Form_Load() procedure of your main form, instantiate the object with CreateObject() and call its StartUp() function like this:
   Err.Clear
   On Error Resume Next
   Set SSCP = CreateObject("SSCProt.SSCProtector")
   If Err.Number Then
   ' if it cant be created - inform the user of the problem and shut down.
   MsgBox ("Unable to connect to the license server. Please contact your vendor.")
   Unload Me
   Exit Sub
   End If
   Dim debugFlags As Long
   Dim return_code As Long
   debugFlags = 0
   Dim MainLicenseFileName, MainLicenseFilePassword, _
   GlobalAuthorizationCodePassword, FingerPrintOptionsCode As String
   MainLicenseFileName = "CPFeaturesSample.ini"
   MainLicenseFilePassword = "austrian_6_abode_._epitome"
   GlobalAuthorizationCodePassword = "featuring_CAMPANILE_2_newscast"
   FingerPrintOptionsCode = 6553703
   ' NOTE when running VB programs from the IDE the applications path is set to the IDEs path - so we must
   ' perform the following absolute path conversion to debug our programs. While this is not necessary
   ' in released binaries - it shouldn't hurt
   MainLicenseFileName = App.Path & "\CPFeaturesSample.ini"
   ' initialize the ClientProtector and Start it up
   SSCP.StartUp MainLicenseFileName, MainLicenseFilePassword, _
   GlobalAuthorizationCodePassword, FingerPrintOptionsCode, _
   debugFlags, return_code

When you referenced the component in the "Project References Dialog" the IDE also has visibility to the enumerated constants defined in RETURNCODES and CPDEBUGFLAGS (inside COM server). You have access to these defined constants directly.